// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    // LIFE-CYCLE CALLBACKS:
    @property('number')
    h: number = 300

    onLoad () {
      this.node.on('mousedown', this.clicked, this)
    }

    clicked (evt: cc.Event.EventMouse) {
      cc.tween(this.node)
      .by(0.5, { position: cc.v3(0, -this.h, 0) }, { easing: 'quardIn' }) // 加速下降
      .by(0.2, { position: cc.v3(0, this.h/6, 0) }, { easing: 'quardOut' }) // 减速上升
      .by(0.2, { position: cc.v3(0, -this.h/6, 0) }, { easing: 'quardIn' }) // 再加速下降
      .by(0.2, { position: cc.v3(0, this.h/8, 0) }, { easing: 'quardOut' }) // 减速上升
      .by(0.2, { position: cc.v3(0, -this.h/8, 0) }, { easing: 'quardIn' }) // 再加速下降
      .start()
    }

    start () {

    }

    // update (dt) {}
}
